name: Spell CI

on:
  push:
    branches: ["artifact"]
    tags: ["v*"]

jobs:
  build-jar:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'temurin'
      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
      - name: Build with Gradle
        uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
        with:
          arguments: build
      - uses: actions/upload-artifact@v3
        with:
          name: package-jar
          path: build/libs
  build-native-ubuntu:
    name: ${{ matrix.version }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        version: [ latest ]
        os: [ macos-latest, windows-latest, ubuntu-latest ]
    steps:
      - uses: actions/checkout@v3
      - name: Set up graalvm 17
        uses: graalvm/setup-graalvm@v1
        with:
          version: ${{ matrix.version }}
          java-version: '17'
          components: 'native-image'
          github-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
      - name: Build native with Gradle
        uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
        with:
          arguments: nativeCompile
      - uses: actions/upload-artifact@v3
        with:
          name: package-native-${{ matrix.os }}
          path: build/native/nativeCompile